<%--
  Created by IntelliJ IDEA.
  User: You
  Date: 2020/5/20
  Time: 11:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*,com.xingyun.info_manager.entity.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
</head>
<div class="layui-container">
    <div class="layui-row">
        <div class="layui-col-lg12">
            <%--<fieldset class="layui-elem-field">--%>
                <%--<legend>新增病人信息</legend>--%>
                <div class="layui-field-box">
                    <form id="formAdd" class="layui-form " action="">
                        <div class="layui-form-item">
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">姓名<span style="color: red">*</span></label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <input type="text" name="patName" placeholder="请输入姓名"  class="layui-input">
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">年龄</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <input type="text" name="age" lay-verify="number" placeholder="请输入年龄" autocomplete="off" class="layui-input">
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">手机号<span style="color: red">*</span></label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <input type="text" id="phone" name="phone" lay-verify="phone" placeholder="请输入手机号"  class="layui-input">
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">微信号<span style="color: red">*</span></label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <input type="text" name="wechat" placeholder="请输入微信号"  class="layui-input">
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">性别</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <select name="gender" >
                                            <option value="1">男</option>
                                            <option value="2">女</option>
                                        </select>
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">是否来院</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <select name="isComeHospital" disabled>
                                            <option value="9">请选择</option>
                                            <option value="1">是</option>
                                            <option value="2">否</option>
                                        </select>
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">预约科室</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <input type="text" name="appointDept" placeholder="请输入预约科室"  class="layui-input">
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">病种</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <input type="text" name="diseaseEntities" placeholder="请输入病种"  class="layui-input">
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">咨询方式</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <select name="consultType" lay-verify="required">
                                            <option value="9">请选择</option>
                                            <option value="1">商务通</option>
                                            <option value="2">电话</option>
                                            <option value="3">市场电话</option>
                                            <option value="4">商转微</option>
                                            <option value="5">微信</option>
                                        </select>
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">预约时间</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <input type="text" name="appointTime" placeholder="请输入预约时间" class="layui-input" id="date1">
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">接诊医生</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <input type="text" name="attendDoctor" placeholder="请输入接诊医生"  class="layui-input">
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">是否复诊</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <select name="subsequentVisit" >
                                            <option value="9">请选择</option>
                                            <option value="1">是</option>
                                            <option value="2">否</option>
                                        </select>
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">治疗项目</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <input type="text" name="treatmentItems" placeholder="请输入治疗项目"  class="layui-input">
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">是否住院</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <select name="isInHospital">
                                            <option value="9">请选择</option>
                                            <option value="1">是</option>
                                            <option value="2">否</option>
                                        </select>
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">消费金额</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <input type="text" name="totalMoney" placeholder="请输入消费金额"  class="layui-input">
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm3">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">是否回访</label>
                                    <div class="layui-input-inline" style="width: 150px;">
                                        <select name="returnVisit">
                                            <option value="9">请选择</option>
                                            <option value="1">是</option>
                                            <option value="2">否</option>
                                        </select>
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-col-sm4">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">患者情况:</label>
                                    <div class="layui-input-inline" style="width: 300px;">
                                        <textarea name="patSituation" placeholder="请输入患者情况" class="layui-textarea"></textarea>
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>

                            <div class="layui-col-sm4">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 60px;text-align: left;">患者意向:</label>
                                    <div class="layui-input-inline" style="width: 300px;">
                                        <textarea name="patIntention" placeholder="请输入患者意向" class="layui-textarea"></textarea>
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                            <div class="layui-col-sm4">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 120px;text-align: left;">未到院回访情况:</label>
                                    <div class="layui-input-inline" style="width: 300px;">
                                        <textarea name="notComeReason" placeholder="请输入回访情况" class="layui-textarea"></textarea>
                                    </div>
                                    <%--<div class="layui-form-mid layui-word-aux">辅助文字</div>--%>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item" style="margin-left: 465px;">
                            <ul >
                                <li style="float:left;">
                                    <div class="" style="">
                                        <button id="commitBtn" class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
                                    </div>
                                </li>
                                <li style="float:left;margin-left: 25px">
                                    <div class="" style="">
                                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>
            <%--</fieldset>--%>
        </div>
    </div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/javascript/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/layui/layui.all.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/javascript/dw_form_submit.js"></script>
<script>

    //时间控件
    var laydate = layui.laydate;

    var startTime = '';
    //执行一个laydate实例
    laydate.render({
        elem: '#date1' //指定元素
        ,format: 'yyyy-MM-dd' //可任意组合

        // ,range: true //或 range: '~' 来自定义分割字符
        // ,done: function(value, date, endDate){
        //     startTime = value;
        //     console.log(value); //得到日期生成的值，如：2017-08-18
        //     // console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
        //     // console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。
        // }
    });

    var form = layui.form;
    // 自定义校验规则
    //这个里面的title、number就写在Html 代码中lay-verify的属性值，即可
    //例如：lay-verify="title"
    // form.verify({
    //     title : function(value) {
    //         if (value.length < 5) {
    //             return '至少输入5个字符啊';
    //         }
    //     },
    //     number : [/^[0-9]*$/, '必须输入数字啊']
    // });

    // 监听提交
    form.on('submit(formDemo)', function(data) {
        var phone = $("#phone").val();
        if(phone){
            console.log("phone存在:"+phone)
            $.ajax({
                url : '${pageContext.request.contextPath}/patnet/phonemsg?id=0',//数据接口
                type : 'post',
                contentType: "application/x-www-form-urlencoded",
                dataType : 'json',
                data: {"phone":phone},//转化json格式
                success : function(data) {
                    if(data.code == 1){
                        //弹出框提示
                        layer.msg(data.msg);
                    } else {
                        addSubmit();
                    }
                }
            });
        } else {
            console.log("phone不存在！")
            addSubmit();
        }
        return false;
    });

    /*提交方法*/
    function addSubmit(){
        $.ajax({
            url : '${pageContext.request.contextPath}/patnet/add',//数据接口
            type : 'post',
            contentType: "application/x-www-form-urlencoded",
            dataType : 'json',
            data: $('#formAdd').serialize(),//转化json格式
            success : function(data) {
                if(data.code == 0){
                    //弹出框提示
                    layer.msg("用户新增成功", {
                        area: '200px',
                        time: 0, //不自动关闭
                        btn: ['确定'],
                        btnAlign: 'c', //按钮居中
                        yes: function(index, layero){
                            //按钮【按钮一】的回调
                            //当你在iframe页面关闭自身时，关闭新增弹出框
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                        }
                    });
                } else {
                    layer.msg(data.msg, {
                        area: '200px',
                        time: 5000, //5s后自动关闭
                        btn: ['确定'],
                        btnAlign: 'c', //按钮居中
                    });
                }
            },
            error:function (data) {
                layer.msg("新增失败", {
                    area: '200px',
                    time: 5000, //5s后自动关闭
                    btn: ['确定'],
                    btnAlign: 'c', //按钮居中
                });
            }
        });
    }

 /*$("#commitBtn").click(function () {
     $.ajax({
         url : '/admin/add',//数据接口
         type : 'post',
         contentType: "application/x-www-form-urlencoded",
         dataType : 'json',
         data: $('#formAdd').serialize(),//转化json格式
         success : function(data) {
             if(data.code == 0){
                 //弹出框提示
                 layer.msg("用户新增成功", {
                     area: '200px',
                     time: 0, //不自动关闭
                     btn: ['确定'],
                     btnAlign: 'c', //按钮居中
                     yes: function(index, layero){
                         //按钮【按钮一】的回调
                         //当你在iframe页面关闭自身时，关闭新增弹出框
                         var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                         parent.layer.close(index); //再执行关闭
                     }
                 });
             } else {
                 layer.msg(data.msg, {
                     area: '200px',
                     time: 5000, //5s后自动关闭
                     btn: ['确定'],
                     btnAlign: 'c', //按钮居中
                 });
             }
         },
         error:function (data) {
             layer.msg("新增失败", {
                 area: '200px',
                 time: 5000, //5s后自动关闭
                 btn: ['确定'],
                 btnAlign: 'c', //按钮居中
             });
         }
     });
 })*/

</script>
</body>
</html>
